<?
session_start();
//*********************************************************************
class Criminal_Lawsuit_Class
{//start_class
//*********************************************************************
	var $hostname_BMConnectionDB ;
	var $database_BMConnectionDB ;
	var $username_BMConnectionDB ;
	var $password_BMConnectionDB ;
//*********************************************************************
	function Criminal_Lawsuit_Class()
		{
			if(file_exists('../../../Connections/BMConnectionDB.php'))
				include('../../../Connections/BMConnectionDB.php');
			else if(file_exists('../../Connections/BMConnectionDB.php'))
				include('../../Connections/BMConnectionDB.php');
			else if(file_exists('../Connections/BMConnectionDB.php'))
					include('../Connections/BMConnectionDB.php');
			else if(file_exists('Connections/BMConnectionDB.php'))
					include('Connections/BMConnectionDB.php');
			$this->hostname_BMConnectionDB=$hostname_BMConnectionDB;
			$this->database_BMConnectionDB=$database_BMConnectionDB;
			$this->username_BMConnectionDB=$username_BMConnectionDB;
			$this->password_BMConnectionDB=$password_BMConnectionDB;
		}
//***********************************************************************
	function Get_Criminal_Lawsuit($Lawsuit_Id)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Store_Recordset = "SELECT * FROM criminal_lawsuit_co_4 WHERE  Lawsuit_No_Criminal_Lawsuit=$Lawsuit_Id";
			$Store_Recordset = mysql_query($query_Store_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Store_Recordset = mysql_fetch_assoc($Store_Recordset);
		
			return $row_Store_Recordset;
		} 
//***********************************************************************
	function Insert_Criminal_Lawsuit($Coming_Date,$Crime_Type,$Objection_Continuation_Date,$Comment,$Judgement_Case,$Lawsuit_Case,$Emp_No,$Year_Lawsuit_No,$Person_Identity_Suspect,$Lawsuit_Type,$Meeting_NO,$Meeting_Time,$Judgement_Summary,$Lawsuit_No_Criminal_Lawsuit)
		{
		   
		   $insertSQL = sprintf("INSERT INTO criminal_lawsuit_co_4 (Lawsuit_No_Criminal_Lawsuit, Coming_Date, Crime_Type, Emp_No, Year_Lawsuit_No, Person_Identity_Suspect, Lawsuit_Type, Meeting_NO, Meeting_Time) VALUES ( %s, %s, %s, %s,%s, %s, %s,%s,%s)",
                       $Lawsuit_No_Criminal_Lawsuit,$Coming_Date,$Crime_Type,$Emp_No,$Year_Lawsuit_No,$Person_Identity_Suspect,$Lawsuit_Type,$Meeting_NO, $Meeting_Time
					   );
						
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$Result1 = mysql_query($insertSQL, $BMConnectionDB) or die(mysql_error());
		}
//*********************************************************************
	function Delete_Criminal_Lawsuit($Temp_Criminal_Lawsuit)
		{
		
				$deleteSQL = sprintf("DELETE FROM criminal_lawsuit_co_4 WHERE  Lawsuit_No_Criminal_Lawsuit=%s",
                       $Temp_Criminal_Lawsuit);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
	function Update_Criminal_Lawsuit($Coming_Date,$Crime_Type,$Objection_Continuation_Date,$Comment,$Judgement_Case,$Lawsuit_Case,$Emp_No,$Year_Lawsuit_No,$Person_Identity_Suspect,$Lawsuit_Type,$Meeting_NO,$Meeting_Time,$Judgement_Summary,$Lawsuit_No_Criminal_Lawsuit)
		{//start_function
								
				$updateSQL = sprintf("UPDATE criminal_lawsuit_co_4 SET Coming_Date=%s, Crime_Type=%s, Objection_Continuation_Date=%s, Comment=%s, Judgement_Case=%s, Lawsuit_Case=%s, Emp_No=%s, Year_Lawsuit_No=%s, Person_Identity_Suspect=%s, Lawsuit_Type=%s, Meeting_NO=%s, Meeting_Time=%s, Judgement_Summary=%s WHERE Lawsuit_No_Criminal_Lawsuit=%s",
                		$Coming_Date,$Crime_Type,$Objection_Continuation_Date,$Comment,$Judgement_Case,$Lawsuit_Case,$Emp_No,$Year_Lawsuit_No,$Person_Identity_Suspect,$Lawsuit_Type,$Meeting_NO,$Meeting_Time,$Judgement_Summary,$Lawsuit_No_Criminal_Lawsuit
			   			);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($updateSQL, $BMConnectionDB) or die(mysql_error());

		}//end_function
//*********************************************************************
		function Total_Criminal_Lawsuits_Number()
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Total_Person_Recordset1 = "SELECT criminal_lawsuit_co_4.Lawsuit_No_Criminal_Lawsuit FROM criminal_lawsuit_co_4";
				$Total_Person_Recordset1 = mysql_query($query_Total_Person_Recordset1, $BMConnectionDB) or die(mysql_error());
				$row_Total_Person_Recordset1 = mysql_fetch_assoc($Total_Person_Recordset1);
				$totalRows_Total_Person_Recordset1 = mysql_num_rows($Total_Person_Recordset1);
				return $totalRows_Total_Person_Recordset1;
			}
//*********************************************************************
}//end_class
//*********************************************************************
class Executive_Lawsuit_Class extends Criminal_Lawsuit_Class
{//start_class
//***********************************************************************
	function Get_Executive_Lawsuit($Lawsuit_Id)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Store_Recordset = "SELECT * FROM executive_lawsuit_archive_co_9 WHERE  Lawsuit_Serial_NO_Executive_Lawsuit=$Lawsuit_Id";
			$Store_Recordset = mysql_query($query_Store_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Store_Recordset = mysql_fetch_assoc($Store_Recordset);
		
			return $row_Store_Recordset;
		} 
//***********************************************************************
	function Insert_Executive_Lawsuit($Coming_Date,$Crime_Type,$Objection_Continuation_Date,$Comment,$Judgement_Case,$Lawsuit_Case,$Emp_No,$Year_Lawsuit_No,$Person_Identity_Suspect,$Lawsuit_Type,$Meeting_NO,$Meeting_Time,$Judgement_Summary,$Lawsuit_No_Criminal_Lawsuit)
		{
		   
		   $insertSQL = sprintf("INSERT INTO executive_lawsuit_archive_co_9 (Lawsuit_No_Criminal_Lawsuit, Coming_Date, Crime_Type, Emp_No, Year_Lawsuit_No, Person_Identity_Suspect, Lawsuit_Type, Meeting_NO, Meeting_Time) VALUES ( %s, %s, %s, %s,%s, %s, %s,%s,%s)",
                       $Lawsuit_No_Criminal_Lawsuit,$Coming_Date,$Crime_Type,$Emp_No,$Year_Lawsuit_No,$Person_Identity_Suspect,$Lawsuit_Type,$Meeting_NO, $Meeting_Time
					   );
						
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$Result1 = mysql_query($insertSQL, $BMConnectionDB) or die(mysql_error());
		}
//*********************************************************************
	function Delete_Executive_Lawsuit($Temp_Criminal_Lawsuit)
		{
		
				$deleteSQL = sprintf("DELETE FROM executive_lawsuit_archive_co_9 WHERE   Lawsuit_Serial_NO_Executive_Lawsuit=%s",
                       $Temp_Criminal_Lawsuit);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
	function Update_Executive_Lawsuit($Information_No, $Information_Date, $Court_Name,  $Year_Lawsuit_No, $Execution_Procedure, $Comment, $Lawsuit_Serial_NO_Executive_Lawsuit)
		{//start_function
								
				$updateSQL = sprintf("UPDATE executive_lawsuit_archive_co_9 SET Information_No=%s, Information_Date=%s, Court_Name=%s,  Year_Lawsuit_No=%s, Execution_Procedure=%s, Comment=%s WHERE Lawsuit_Serial_NO_Executive_Lawsuit=%s",
                		$Information_No, $Information_Date, $Court_Name,  $Year_Lawsuit_No, $Execution_Procedure, $Comment, $Lawsuit_Serial_NO_Executive_Lawsuit
			   			);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($updateSQL, $BMConnectionDB) or die(mysql_error());

		}//end_function
//*********************************************************************
		function Total_Executive_Lawsuits_Number()
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Total_Person_Recordset1 = "SELECT   Lawsuit_Serial_NO_Executive_Lawsuit FROM executive_lawsuit_archive_co_9";
				$Total_Person_Recordset1 = mysql_query($query_Total_Person_Recordset1, $BMConnectionDB) or die(mysql_error());
				$row_Total_Person_Recordset1 = mysql_fetch_assoc($Total_Person_Recordset1);
				$totalRows_Total_Person_Recordset1 = mysql_num_rows($Total_Person_Recordset1);
				return $totalRows_Total_Person_Recordset1;
			}
//*********************************************************************
}//end_class
//*********************************************************************
class Conditions_Class
{//start_class
//*********************************************************************
	var $hostname_BMConnectionDB ;
	var $database_BMConnectionDB ;
	var $username_BMConnectionDB ;
	var $password_BMConnectionDB ;
//*********************************************************************
	function Conditions_Class()
		{
			if(file_exists('../../../Connections/BMConnectionDB.php'))
				include('../../../Connections/BMConnectionDB.php');
			else if(file_exists('../../Connections/BMConnectionDB.php'))
				include('../../Connections/BMConnectionDB.php');
			else if(file_exists('../Connections/BMConnectionDB.php'))
					include('../Connections/BMConnectionDB.php');
			else if(file_exists('Connections/BMConnectionDB.php'))
					include('Connections/BMConnectionDB.php');
			$this->hostname_BMConnectionDB=$hostname_BMConnectionDB;
			$this->database_BMConnectionDB=$database_BMConnectionDB;
			$this->username_BMConnectionDB=$username_BMConnectionDB;
			$this->password_BMConnectionDB=$password_BMConnectionDB;
		}
//***********************************************************************
	function Get_Conditions($Temp_License_Recored_Id)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Conditions_Recordset = "SELECT * FROM condition_oc_3 WHERE License_Recored_Id=$Temp_License_Recored_Id";
			$Conditions_Recordset = mysql_query($query_Conditions_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Conditions_Recordset = mysql_fetch_assoc($Conditions_Recordset);

			$i=0;
			do  { 
					$Display_Conditions_Array[$i]= $row_Conditions_Recordset['Condition']; 
					++$i;
         		} while ($row_Conditions_Recordset = mysql_fetch_assoc($Conditions_Recordset)); 
			return $Display_Conditions_Array;
		} 
//***********************************************************************
	function Insert_Conditions($Condition_Array,$Temp_License_Recored_Id)
		{
			for($i=0;$i<5;$i++)
			{
			if($Condition_Array[$i]!='')
 				{
					$insertSQL = sprintf("INSERT INTO condition_oc_3 (Condition_Id, Condition, License_recored_Id) VALUES (%s, %s, %s)",
                       $i+1,
					   $Condition_Array[$i],
                       $Temp_License_Recored_Id
					   );

					$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  					mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
					$Result1 = mysql_query($insertSQL, $BMConnectionDB) or die(mysql_error());
				}
			}
		}
//*********************************************************************
	function Delete_Conditions($Temp_License_Recored_Id)
		{
				$deleteSQL = sprintf("DELETE FROM condition_oc_3 WHERE License_Recored_Id=%s",
                       $Temp_License_Recored_Id);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
		function Total_Conditions_Number()
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Total_Person_Recordset1 = "SELECT store_oc_1.Store_Id FROM store_oc_1";
				$Total_Person_Recordset1 = mysql_query($query_Total_Person_Recordset1, $BMConnectionDB) or die(mysql_error());
				$row_Total_Person_Recordset1 = mysql_fetch_assoc($Total_Person_Recordset1);
				$totalRows_Total_Person_Recordset1 = mysql_num_rows($Total_Person_Recordset1);
				return $totalRows_Total_Person_Recordset1;
			}
//***********************************************************************
}//end_class
//*********************************************************************
class Generall_Class
{//start_class
//*********************************************************************
	var $hostname_BMConnectionDB ;
	var $database_BMConnectionDB ;
	var $username_BMConnectionDB ;
	var $password_BMConnectionDB ;
//*********************************************************************
	function Generall_Class()
		{
			if(file_exists('../../../Connections/BMConnectionDB.php'))
				include('../../../Connections/BMConnectionDB.php');
			else if(file_exists('../../Connections/BMConnectionDB.php'))
				include('../../Connections/BMConnectionDB.php');
			else if(file_exists('../Connections/BMConnectionDB.php'))
					include('../Connections/BMConnectionDB.php');
			else if(file_exists('Connections/BMConnectionDB.php'))
					include('Connections/BMConnectionDB.php');
			$this->hostname_BMConnectionDB=$hostname_BMConnectionDB;
			$this->database_BMConnectionDB=$database_BMConnectionDB;
			$this->username_BMConnectionDB=$username_BMConnectionDB;
			$this->password_BMConnectionDB=$password_BMConnectionDB;
		}
//*********************************************************************
	function Get_System_Date()
		{
			$Generall_Object=new Generall_Class();
			$Sys_Month=date("m",time());settype($Sys_Month,int);
			$Sys_Year =date("Y",time());settype($Sys_Year,int);
			$Sys_Day  =date("d",time());settype($Sys_Day,int);
			$Sys_Date="$Sys_Year"."-"."$Sys_Month"."-"."$Sys_Day";
			return $Generall_Object->GetSQLValueString($Sys_Date,"date");
		}
//*********************************************************************
	function Is_Start_Year()
		{
			$Month=date("m",time());
			$Day=date("d",time());
			if($Month==1 && $Day)
				return true;
			else
				return false;
		}
//*********************************************************************
function Get_Next_Request_Id($Table,$Column,$Date_Column,$Equal_Or_Greater)
{//start function
					
		$Sys_Year =date("Y",time());
		$Start_Year_Date="'"."$Sys_Year"."-1-1"."'";
		//printf($Start_Year_Date);
		$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  		mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
		$query_Recordset1 = "SELECT".  "  $Column  "."  FROM  "."  $Table  "."  WHERE "." $Date_Column  "." $Equal_Or_Greater  "." $Start_Year_Date"."ORDER BY  "."  $Column";
		$Recordset1 = mysql_query($query_Recordset1, $BMConnectionDB) or die(mysql_error());
		$totalRows_Recordset1 = mysql_num_rows($Recordset1);
		$row_Recordset1 = mysql_fetch_assoc($Recordset1);	
		$i=0;
		//*********************
		switch($Table)
			{
				case "license_request_recoreds_oc_5" :
								do {
									++$i;
									if($totalRows_Recordset1==$i)
										{
											return $row_Recordset1['License_Recored_Id'];
										}	
 	   								} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
					break;	
				//***************
								case "license_recored_oc_14" :
								do {
									++$i;
									if($totalRows_Recordset1==$i)
										{
											return $row_Recordset1['License_Id'];
										}	
 	   								} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
					break;	
				//***************
				case "containers_fixing_request_recordes_gt_7" :
								do {
									++$i;
									if($totalRows_Recordset1==$i)
										{
											return $row_Recordset1['Containers_Fixing_Recordes_Id'];
										}	
 	   								} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
					break;	
				//***************
				case "interior_cr_3" :
								do {
									++$i;
									if($totalRows_Recordset1==$i)
										{
											return $row_Recordset1['Interior_Id'];
										}	
 	   								} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
					break;	
				//***************
				case "exterior_cr_2" :
								do {
									++$i;
									if($totalRows_Recordset1==$i)
										{
											return $row_Recordset1['Exterior_Id'];
										}	
 	   								} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
					break;	
				//***************
			}
}//end function
//************************************************************************
	function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
		{
  			$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  			switch ($theType) 
			{
    			case "text":
     			 	$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      				break;    
    			case "long":
    			case "int":
      				$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      				break;
    			case "double":
      				$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      				break;
    			case "date":
      				$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      				break;
   			    case "defined":
      				$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      				break;
  			}
  			return $theValue;
		}
//***********************************************************************
function Get_Value_String($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ?  $theValue  : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ?  doubleval($theValue)  : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ?  $theValue  : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
//***********************************************************************
}//end_class
//*********************************************************************
class Store_Class
{//start_class
//*********************************************************************
	var $hostname_BMConnectionDB ;
	var $database_BMConnectionDB ;
	var $username_BMConnectionDB ;
	var $password_BMConnectionDB ;
//*********************************************************************
	function Store_Class()
		{
			if(file_exists('../../../Connections/BMConnectionDB.php'))
				include('../../../Connections/BMConnectionDB.php');
			else if(file_exists('../../Connections/BMConnectionDB.php'))
				include('../../Connections/BMConnectionDB.php');
			else if(file_exists('../Connections/BMConnectionDB.php'))
					include('../Connections/BMConnectionDB.php');
			else if(file_exists('Connections/BMConnectionDB.php'))
					include('Connections/BMConnectionDB.php');
			$this->hostname_BMConnectionDB=$hostname_BMConnectionDB;
			$this->database_BMConnectionDB=$database_BMConnectionDB;
			$this->username_BMConnectionDB=$username_BMConnectionDB;
			$this->password_BMConnectionDB=$password_BMConnectionDB;
		}
//*********************************************************************
	function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
		{
  			$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  			switch ($theType) 
			{
    			case "text":
     			 	$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      				break;    
    			case "long":
    			case "int":
      				$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      				break;
    			case "double":
      				$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      				break;
    			case "date":
      				$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      				break;
   			    case "defined":
      				$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      				break;
  			}
  			return $theValue;
		}
//***********************************************************************
	function Get_Store($Store_Id)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Store_Recordset = "SELECT store_oc_1.Store_Id, store_oc_1.Person_Identity, store_oc_1.Address FROM store_oc_1 WHERE  Store_Id=$Store_Id";
			$Store_Recordset = mysql_query($query_Store_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Store_Recordset = mysql_fetch_assoc($Store_Recordset);
		
			return $row_Store_Recordset;
		} 
//***********************************************************************
	function Insert_Store($Store_Id,$Address,$Area,$Height,$Person_Identity,$Street_Id)
		{
		   
		   $insertSQL = sprintf("INSERT INTO store_oc_1 (Store_Id, Address, Area, Height, Person_Identity, Street_Id) VALUES (%s, %s, %s, %s, %s, %s)",
                       $Store_Id,$Address,$Area,$Height,$Person_Identity,$Street_Id
					   );
						
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$Result1 = mysql_query($insertSQL, $BMConnectionDB) or die(mysql_error());
		}
//*********************************************************************
	function Delete_Store($Temp_Store_Id)
		{
		
				$deleteSQL = sprintf("DELETE FROM store_oc_1 WHERE Store_Id=%s",
                       $Temp_Store_Id);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
	function Update_Store($Store_Id,$Address,$Area,$Height,$Person_Identity,$Street_Id)
		{//start_function
								
				$updateSQL = sprintf("UPDATE store_oc_1 SET Address=%s, Area=%s, Height=%s, Person_Identity=%s, Street_Id=%s WHERE Store_Id=%s",
                		$Address,$Area,$Height,$Person_Identity,$Street_Id,$Store_Id
			   			);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($updateSQL, $BMConnectionDB) or die(mysql_error());

		}//end_function
//*********************************************************************
		function Total_Stores_Number()
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Total_Person_Recordset1 = "SELECT store_oc_1.Store_Id FROM store_oc_1";
				$Total_Person_Recordset1 = mysql_query($query_Total_Person_Recordset1, $BMConnectionDB) or die(mysql_error());
				$row_Total_Person_Recordset1 = mysql_fetch_assoc($Total_Person_Recordset1);
				$totalRows_Total_Person_Recordset1 = mysql_num_rows($Total_Person_Recordset1);
				return $totalRows_Total_Person_Recordset1;
			}

//***********************************************************************
	function  Check_Unique_Store_Famous_Name($Temp_Famouse_Name)
		{
					$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  					mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);

					mysql_select_db($database_BMConnectionDB, $BMConnectionDB);
					$query_Store_Name_Recordset = "SELECT  license_request_recoreds_oc_5.Store_Famous_Name FROM  license_request_recoreds_oc_5 WHERE  Store_Famous_Name=$Temp_Famouse_Name";
					$Store_Name_Recordset = mysql_query($query_Store_Name_Recordset, $BMConnectionDB) or die(mysql_error());
					$row_Store_Name_Recordset = mysql_fetch_assoc($Store_Name_Recordset);
					$totalRows_Store_Name_Recordset = mysql_num_rows($Store_Name_Recordset);

					if($totalRows_Store_Name_Recordset>0)
						return false;
					else
						return true;
				
		}//
//***********************************************************************
}//end_class
//*********************************************************************
class Container_Class
{//start_class
//*********************************************************************
	var $hostname_BMConnectionDB ;
	var $database_BMConnectionDB ;
	var $username_BMConnectionDB ;
	var $password_BMConnectionDB ;
//*********************************************************************
	function Container_Class()
		{
			if(file_exists('../../../Connections/BMConnectionDB.php'))
				include('../../../Connections/BMConnectionDB.php');
			else if(file_exists('../../Connections/BMConnectionDB.php'))
				include('../../Connections/BMConnectionDB.php');
			else if(file_exists('../Connections/BMConnectionDB.php'))
					include('../Connections/BMConnectionDB.php');
			else if(file_exists('Connections/BMConnectionDB.php'))
					include('Connections/BMConnectionDB.php');
			$this->hostname_BMConnectionDB=$hostname_BMConnectionDB;
			$this->database_BMConnectionDB=$database_BMConnectionDB;
			$this->username_BMConnectionDB=$username_BMConnectionDB;
			$this->password_BMConnectionDB=$password_BMConnectionDB;
		}
//*********************************************************************
	function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
		{
  			$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  			switch ($theType) 
			{
    			case "text":
     			 	$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      				break;    
    			case "long":
    			case "int":
      				$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      				break;
    			case "double":
      				$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      				break;
    			case "date":
      				$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      				break;
   			    case "defined":
      				$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      				break;
  			}
  			return $theValue;
		}
//*********************************************************************
		function Total_Containers_Number()
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Total_Person_Recordset1 = "SELECT Containers_Id FROM containers_gt_1";
				$Total_Person_Recordset1 = mysql_query($query_Total_Person_Recordset1, $BMConnectionDB) or die(mysql_error());
				$row_Total_Person_Recordset1 = mysql_fetch_assoc($Total_Person_Recordset1);
				$totalRows_Total_Person_Recordset1 = mysql_num_rows($Total_Person_Recordset1);
				return $totalRows_Total_Person_Recordset1;
			}
//***********************************************************************
	function Get_Container($Container_Id)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Store_Recordset = "SELECT containers_gt_1.Containers_Id, from containers_gt_1 WHERE  Containers_Id=$Container_Id";
			$Store_Recordset = mysql_query($query_Store_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Store_Recordset = mysql_fetch_assoc($Store_Recordset);
		
			return $row_Store_Recordset;
		} 
//***********************************************************************
	function Insert_Container($Containers_Id,$Size,$Street_Id)
		{
		   
  				$insertSQL = sprintf("INSERT INTO containers_gt_1 (Containers_Id, `Size`, Street_Id) VALUES (%s, %s, %s)",
                       $Containers_Id,$Size,$Street_Id
					   );
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$Result1 = mysql_query($insertSQL, $BMConnectionDB) or die(mysql_error());
		}
//*********************************************************************
	function Delete_Container($Temp_Container_Id)
		{
				$deleteSQL = sprintf("DELETE FROM containers_gt_1 WHERE Containers_Id=%s",
                       $Temp_Container_Id);
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
	function Update_Container($Containers_Id,$Size,$Street_Id)
		{//start_function
  				$updateSQL = sprintf("UPDATE containers_gt_1 SET `Size`=%s, Street_Id=%s WHERE Containers_Id=%s",
                		$Size,$Street_Id,$Containers_Id
			   			);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($updateSQL, $BMConnectionDB) or die(mysql_error());

		}//end_function
//*********************************************************************
}//end_class
//*********************************************************************
//*********************************************************************
class Emp_Class
{//start_class
//*********************************************************************
	var $hostname_BMConnectionDB ;
	var $database_BMConnectionDB ;
	var $username_BMConnectionDB ;
	var $password_BMConnectionDB ;
//*********************************************************************
	function Emp_Class()
		{
			if(file_exists('../../../Connections/BMConnectionDB.php'))
				include('../../../Connections/BMConnectionDB.php');
			else if(file_exists('../../Connections/BMConnectionDB.php'))
				include('../../Connections/BMConnectionDB.php');
			else if(file_exists('../Connections/BMConnectionDB.php'))
					include('../Connections/BMConnectionDB.php');
			else if(file_exists('Connections/BMConnectionDB.php'))
					include('Connections/BMConnectionDB.php');

			$this->hostname_BMConnectionDB=$hostname_BMConnectionDB;//"127.0.0.1";//$hostname_BMConnectionDB;
			$this->database_BMConnectionDB=$database_BMConnectionDB;//"BethlehemMunicipalityDB";
			$this->username_BMConnectionDB=$username_BMConnectionDB;//"root";
			$this->password_BMConnectionDB=$password_BMConnectionDB;//"";
		}
//*********************************************************************
	function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
		{
  			$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  			switch ($theType) 
			{
    			case "text":
     			 	$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      				break;    
    			case "long":
    			case "int":
      				$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      				break;
    			case "double":
      				$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      				break;
    			case "date":
      				$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      				break;
   			    case "defined":
      				$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      				break;
  			}
  			return $theValue;
		}
//*********************************************************************
	function Get_Emp($User_Name)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Emp_Recordset = "SELECT * FROM employee_admin_9 WHERE  User_Name=$User_Name";
			$Emp_Recordset = mysql_query($query_Emp_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Emp_Recordset = mysql_fetch_assoc($Emp_Recordset);
		
			return $row_Emp_Recordset;
		} 
//***********************************************************************
	function Insert_Emp($Employee_Id, $Identity, $First_Name, $Father_Name, $GrandFather_Name, $Family_Name, $Cell_No, $Job_Id, $Department_Id, $Salary, $Hire_Date, $User_Name, $Pass_Word,$Picture,$Email)
		{
		   
		   $insertSQL = sprintf("INSERT INTO employee_admin_9 (Employee_Id, `Identity`, First_Name, Father_Name, GrandFather_Name, Family_Name, Cell_No, Job_Id, Department_Id, Salary, Hire_Date, User_Name, Pass_Word,Picture,Email) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s)",
                       		$Employee_Id, $Identity, $First_Name, $Father_Name, $GrandFather_Name, $Family_Name, $Cell_No, $Job_Id, $Department_Id, $Salary, $Hire_Date, $User_Name, $Pass_Word,$Picture,$Email);
						
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				
				$Result1 = mysql_query($insertSQL, $BMConnectionDB) or die(mysql_error());
		}
//*********************************************************************
	function Delete_Emp($Temp_Emp_Id)
		{
				$deleteSQL = sprintf("DELETE FROM employee_admin_9 WHERE Employee_Id=%s",
                       $Temp_Emp_Id);
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
	function Update_Emp($Identity, $First_Name, $Father_Name,$GrandFather_Name,$Family_Name, $Birth_Date, $Cell_No, $Job_Id, $Department_Id, $Salary, $Hire_Date, $User_Name, $Address, $Tel_No, $Email ,$Sex,$Employee_Id)
		{//start_function
								
				$updateSQL = sprintf("UPDATE employee_admin_9 SET `Identity`=%s, First_Name=%s, Father_Name=%s, GrandFather_Name=%s, Family_Name=%s, Birth_Date=%s, Cell_No=%s, Job_Id=%s, Department_Id=%s, Salary=%s, Hire_Date=%s, User_Name=%s, Address=%s, Tel_No=%s, Email=%s ,Sex=%s  WHERE Employee_Id=%s",
			   				$Identity, $First_Name, $Father_Name,$GrandFather_Name,$Family_Name, $Birth_Date, $Cell_No, $Job_Id, $Department_Id, $Salary, $Hire_Date, $User_Name, $Address, $Tel_No, $Email ,$Sex,$Employee_Id);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($updateSQL, $BMConnectionDB) or die(mysql_error());

		}//end_function
//*********************************************************************
		function Total_Emps_Number()
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Total_Person_Recordset1 = "SELECT employee_admin_9.Employee_Id FROM employee_admin_9";
				$Total_Person_Recordset1 = mysql_query($query_Total_Person_Recordset1, $BMConnectionDB) or die(mysql_error());
				$row_Total_Person_Recordset1 = mysql_fetch_assoc($Total_Person_Recordset1);
				$totalRows_Total_Person_Recordset1 = mysql_num_rows($Total_Person_Recordset1);
				return $totalRows_Total_Person_Recordset1;
			}
//************************************************************************
	function Get_Last_Index()
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Display_Persone_Recordset = "SELECT  Employee_Id,User_Name, First_Name,Father_Name, GrandFather_Name, Family_Name FROM employee_admin_9 ORDER BY Employee_Id";
			$Display_Persone_Recordset=mysql_query($query_Display_Persone_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset);
			$totalRows_Display_Persone_Recordset = mysql_num_rows($Display_Persone_Recordset);
			$i=0;
			
			do {
            	++$i;
				if($totalRows_Display_Persone_Recordset==$i)
              		return $row_Display_Persone_Recordset['Employee_Id']; 
			   } while ($row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset)); 
		}
//************************************************************************
	function Get_First_Index()
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Display_Persone_Recordset = "SELECT  Employee_Id,User_Name, First_Name,Father_Name, GrandFather_Name, Family_Name FROM employee_admin_9 ORDER BY Employee_Id";
			$Display_Persone_Recordset=mysql_query($query_Display_Persone_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset);
			$totalRows_Display_Persone_Recordset = mysql_num_rows($Display_Persone_Recordset);
			
			do {
              		return $row_Display_Persone_Recordset['Employee_Id']; 
			   } while ($row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset)); 
		}
//************************************************************************
	function Get_Next_Index($Temp_Employee_Id)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Display_Persone_Recordset = "SELECT  Employee_Id,User_Name, First_Name,Father_Name, GrandFather_Name, Family_Name FROM employee_admin_9 ORDER BY Employee_Id";
			$Display_Persone_Recordset=mysql_query($query_Display_Persone_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset);
			$totalRows_Display_Persone_Recordset = mysql_num_rows($Display_Persone_Recordset);
			
			do {
            	if($Temp_Employee_Id==$row_Display_Persone_Recordset['Employee_Id'])
              		{
						$row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset);
						return $row_Display_Persone_Recordset['Employee_Id'];
  					} 
			   } while ($row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset)); 
		}
//************************************************************************
	function Get_Previous_Index($Temp_Employee_Id)
		{//start_function
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$Index_Array=array();
			$query_Display_Persone_Recordset = "SELECT  Employee_Id,User_Name  First_Name,Father_Name, GrandFather_Name, Family_Name FROM employee_admin_9 ORDER BY Employee_Id";
			$Display_Persone_Recordset=mysql_query($query_Display_Persone_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset);
			$totalRows_Display_Persone_Recordset = mysql_num_rows($Display_Persone_Recordset);
			$i=0;
			do {
				$Index_Array[$i]=$row_Display_Persone_Recordset['Employee_Id'];
				if($Temp_Employee_Id==$row_Display_Persone_Recordset['Employee_Id'])
              		{
						return $Index_Array[$i-1];//$Previous_Index;
  					}
				++$i;
			   } while ($row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset)); 
		
	}//end_function
//*********************************************************************
}//end_class
//*********************************************************************
class Worker_Class extends Emp_Class
{//start_class
//*********************************************************************
	var $hostname_BMConnectionDB ;
	var $database_BMConnectionDB ;
	var $username_BMConnectionDB ;
	var $password_BMConnectionDB ;
//*********************************************************************
	function Worker_Class()
		{
			if(file_exists('../../../Connections/BMConnectionDB.php'))
				include('../../../Connections/BMConnectionDB.php');
			else if(file_exists('../../Connections/BMConnectionDB.php'))
				include('../../Connections/BMConnectionDB.php');
			else if(file_exists('../Connections/BMConnectionDB.php'))
					include('../Connections/BMConnectionDB.php');
			else if(file_exists('Connections/BMConnectionDB.php'))
					include('Connections/BMConnectionDB.php');

			$this->hostname_BMConnectionDB=$hostname_BMConnectionDB;
			$this->database_BMConnectionDB=$database_BMConnectionDB;
			$this->username_BMConnectionDB=$username_BMConnectionDB;
			$this->password_BMConnectionDB=$password_BMConnectionDB;
		}
//*********************************************************************
		function Total_Workers_Number()
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Total_Person_Recordset1 = "SELECT worker_gt_4.Worker_Id FROM worker_gt_4";
				$Total_Person_Recordset1 = mysql_query($query_Total_Person_Recordset1, $BMConnectionDB) or die(mysql_error());
				$row_Total_Person_Recordset1 = mysql_fetch_assoc($Total_Person_Recordset1);
				$totalRows_Total_Person_Recordset1 = mysql_num_rows($Total_Person_Recordset1);
				return $totalRows_Total_Person_Recordset1;
			}
//*********************************************************************
	function Delete_Emp($Temp_Emp_Id)
		{
				$deleteSQL = sprintf("DELETE FROM worker_gt_4 WHERE Worker_Id=%s",
                       $Temp_Emp_Id);
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
}//end_class
//*********************************************************************
class Persone_Class
{//start_class
//*********************************************************************
	var $hostname_BMConnectionDB ;
	var $database_BMConnectionDB ;
	var $username_BMConnectionDB ;
	var $password_BMConnectionDB ;
//*********************************************************************
	function Persone_Class()
		{
			if(file_exists('../../../Connections/BMConnectionDB.php'))
				include('../../../Connections/BMConnectionDB.php');
			else if(file_exists('../../Connections/BMConnectionDB.php'))
				include('../../Connections/BMConnectionDB.php');
			else if(file_exists('../Connections/BMConnectionDB.php'))
					include('../Connections/BMConnectionDB.php');
			else if(file_exists('Connections/BMConnectionDB.php'))
					include('Connections/BMConnectionDB.php');

			$this->hostname_BMConnectionDB=$hostname_BMConnectionDB;
			$this->database_BMConnectionDB=$database_BMConnectionDB;
			$this->username_BMConnectionDB=$username_BMConnectionDB;
			$this->password_BMConnectionDB=$password_BMConnectionDB;
		}
//*********************************************************************
	function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
		{
  			$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  			switch ($theType) 
			{
    			case "text":
     			 	$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      				break;    
    			case "long":
    			case "int":
      				$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      				break;
    			case "double":
      				$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      				break;
    			case "date":
      				$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      				break;
   			    case "defined":
      				$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      				break;
  			}
  			return $theValue;
		}
//*********************************************************************
	function Get_Persone($Persone_Id)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Persone_Recordset = "SELECT  *  FROM person_admin_8 WHERE Person_Identity=$Persone_Id";
			$Persone_Recordset = mysql_query($query_Persone_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Persone_Recordset = mysql_fetch_assoc($Persone_Recordset);
		
			return $row_Persone_Recordset;
		} 
//***********************************************************************
	function Insert_Persone($Employee_Id, $Identity, $First_Name, $Father_Name, $GrandFather_Name, $Family_Name, $Cell_No, $Job_Id, $Department_Id, $Salary, $Hire_Date, $User_Name, $Pass_Word,$Picture,$Email)
		{
		   
		   $insertSQL = sprintf("INSERT INTO employee_admin_9 (Employee_Id, `Identity`, First_Name, Father_Name, GrandFather_Name, Family_Name, Cell_No, Job_Id, Department_Id, Salary, Hire_Date, User_Name, Pass_Word,Picture,Email) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s)",
                       		$Employee_Id, $Identity, $First_Name, $Father_Name, $GrandFather_Name, $Family_Name, $Cell_No, $Job_Id, $Department_Id, $Salary, $Hire_Date, $User_Name, $Pass_Word,$Picture,$Email);
						
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				
				$Result1 = mysql_query($insertSQL, $BMConnectionDB) or die(mysql_error());
		}
//*********************************************************************
	function Delete_Persone($Temp_Persone_Id)
		{
		
				$deleteSQL = sprintf("DELETE FROM person_admin_8 WHERE Person_Identity=%s",
                       $Temp_Persone_Id);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
	function Update_Persone($First_Name, $Father_Name, $GrandFather_Name, $Family_Name, $Famous_Name, $Birth_Date, $Address, $Tel_No, $Email, $Craft_Name, $Pass_Word,$Picture,$Person_Identity)
		{//start_function
								
				$updateSQL = sprintf("UPDATE person_admin_8 SET First_Name=%s, Father_Name=%s, GrandFather_Name=%s, Family_Name=%s, Famous_Name=%s, Birth_Date=%s, Address=%s, Tel_No=%s, Email=%s, Craft_Name=%s, Pass_Word=%s,Picture=%s    WHERE Person_Identity=%s",
			   				$First_Name, $Father_Name, $GrandFather_Name, $Family_Name, $Famous_Name, $Birth_Date, $Address, $Tel_No, $Email, $Craft_Name, $Pass_Word,$Picture,$Person_Identity);

				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($updateSQL, $BMConnectionDB) or die(mysql_error());

		}//end_function
//*********************************************************************
		function Total_Persones_Number()
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Total_Person_Recordset1 = "SELECT person_admin_8.Person_Identity FROM person_admin_8";
				$Total_Person_Recordset1 = mysql_query($query_Total_Person_Recordset1, $BMConnectionDB) or die(mysql_error());
				$row_Total_Person_Recordset1 = mysql_fetch_assoc($Total_Person_Recordset1);
				$totalRows_Total_Person_Recordset1 = mysql_num_rows($Total_Person_Recordset1);
				return $totalRows_Total_Person_Recordset1;
			}
//************************************************************************
	function Get_Last_Index()
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Display_Persone_Recordset = "SELECT  Person_Identity, First_Name,Father_Name, GrandFather_Name, Family_Name FROM person_admin_8";
			$Display_Persone_Recordset=mysql_query($query_Display_Persone_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset);
			$totalRows_Display_Persone_Recordset = mysql_num_rows($Display_Persone_Recordset);
			$i=0;
			
			do {
            	++$i;
				if($totalRows_Display_Persone_Recordset==$i)
              		return $row_Display_Persone_Recordset['Person_Identity']; 
			   } while ($row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset)); 
		}
//************************************************************************
	function Get_First_Index()
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Display_Persone_Recordset = "SELECT  Person_Identity, First_Name,Father_Name, GrandFather_Name, Family_Name FROM person_admin_8";
			$Display_Persone_Recordset=mysql_query($query_Display_Persone_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset);
			$totalRows_Display_Persone_Recordset = mysql_num_rows($Display_Persone_Recordset);
			
			do {
              		return $row_Display_Persone_Recordset['Person_Identity']; 
			   } while ($row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset)); 
		}
//************************************************************************
	function Get_Next_Index($Temp_Person_Identity)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Display_Persone_Recordset = "SELECT  Person_Identity, First_Name,Father_Name, GrandFather_Name, Family_Name FROM person_admin_8";
			$Display_Persone_Recordset=mysql_query($query_Display_Persone_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset);
			$totalRows_Display_Persone_Recordset = mysql_num_rows($Display_Persone_Recordset);
			
			do {
            	if($Temp_Person_Identity==$row_Display_Persone_Recordset['Person_Identity'])
              		{
						$row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset);
						return $row_Display_Persone_Recordset['Person_Identity'];
  					} 
			   } while ($row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset)); 
		}
//************************************************************************
	function Get_Previous_Index($Temp_Person_Identity)
		{//start_function
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$Index_Array=array();
			$query_Display_Persone_Recordset = "SELECT  Person_Identity, First_Name,Father_Name, GrandFather_Name, Family_Name FROM person_admin_8";
			$Display_Persone_Recordset=mysql_query($query_Display_Persone_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset);
			$totalRows_Display_Persone_Recordset = mysql_num_rows($Display_Persone_Recordset);
			$i=0;
			do {
				$Index_Array[$i]=$row_Display_Persone_Recordset['Person_Identity'];
				if($Temp_Person_Identity==$row_Display_Persone_Recordset['Person_Identity'])
              		{
						return $Index_Array[$i-1];//$Previous_Index;
  					}
				++$i;
			   } while ($row_Display_Persone_Recordset = mysql_fetch_assoc($Display_Persone_Recordset)); 
	}//end_function
//************************************************************************
}//end_class
//*********************************************************************
class Interior_Class
{//start_class
//*********************************************************************
	var $hostname_BMConnectionDB ;
	var $database_BMConnectionDB ;
	var $username_BMConnectionDB ;
	var $password_BMConnectionDB ;
//*********************************************************************
	function Interior_Class()
		{
			if(file_exists('../../../Connections/BMConnectionDB.php'))
				include('../../../Connections/BMConnectionDB.php');
			else if(file_exists('../../Connections/BMConnectionDB.php'))
				include('../../Connections/BMConnectionDB.php');
			else if(file_exists('../Connections/BMConnectionDB.php'))
					include('../Connections/BMConnectionDB.php');
			else if(file_exists('Connections/BMConnectionDB.php'))
					include('Connections/BMConnectionDB.php');
			$this->hostname_BMConnectionDB=$hostname_BMConnectionDB;
			$this->database_BMConnectionDB=$database_BMConnectionDB;
			$this->username_BMConnectionDB=$username_BMConnectionDB;
			$this->password_BMConnectionDB=$password_BMConnectionDB;
		}
//***********************************************************************
	function Get_Interior($Temp_Interior_Id)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Update_Recordset = "SELECT * FROM interior_cr_3 WHERE Interior_Id=$Temp_Interior_Id";
			$Update_Recordset = mysql_query($query_Update_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Update_Recordset = mysql_fetch_assoc($Update_Recordset);
			return $row_Update_Recordset;
		} 
//***********************************************************************
	function Insert_Interior($Interior_Id, $From, $Supject, $Message,$Coming_Date,$Message_Type)
		{
		   
		   $insertSQL = sprintf("INSERT INTO interior_cr_3 (Interior_Id, `From`, Supject, Message, Coming_Date,Message_Type) VALUES (%s, %s, %s, %s, %s,%s)",
                       $Interior_Id, $From, $Supject, $Message,$Coming_Date,$Message_Type
					   );
						
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$Result1 = mysql_query($insertSQL, $BMConnectionDB) or die(mysql_error());
		}
//*********************************************************************
	function Delete_Interior($Temp_Interior_Id)
		{
  				$deleteSQL = sprintf("DELETE FROM interior_cr_3 WHERE Interior_Id=%s",
                       	$Temp_Interior_Id);
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
		function Total_Interiors_Number($Mail_Type)
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Total_Person_Recordset = "SELECT * FROM interior_cr_3 WHERE Message_Type='$Mail_Type'";
				$Total_Person_Recordset = mysql_query($query_Total_Person_Recordset, $BMConnectionDB) or die(mysql_error());
				return $Total_Person_Recordset;
			}
}//end_class
//*********************************************************************
class Change_Interior_Class  extends Interior_Class
{//start_class
//***********************************************************************
	function Get_Change_Interior($Temp_Interior_Id)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Manpulate_Interior_Mailing_Recordset = "SELECT * FROM change_interior_cr_4  WHERE Interior_Id=$Temp_Interior_Id";
			$Manpulate_Interior_Mailing_Recordset = mysql_query($query_Manpulate_Interior_Mailing_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Manpulate_Interior_Mailing_Recordset = mysql_fetch_assoc($Manpulate_Interior_Mailing_Recordset);
			return $row_Manpulate_Interior_Mailing_Recordset;
		} 
//***********************************************************************
	function Insert_Change_Interior($Interior_Id, $Dept_Id, $Change_Date,$From,$Supject,$Message,$Coming_Date)
		{
		   
		   $insertSQL = sprintf("INSERT INTO change_interior_cr_4 (Interior_Id, Dept_Id, Change_Date,`From`,Supject,Message,Coming_Date) VALUES (%s, %s, %s,%s,%s,%s,%s)",
                       $Interior_Id, $Dept_Id, $Change_Date,$From,$Supject,$Message,$Coming_Date
					   );
						
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$Result1 = mysql_query($insertSQL, $BMConnectionDB) or die(mysql_error());
		}
//*********************************************************************
	function Delete_Change_Interior($Temp_Interior_Id)
		{
  				$deleteSQL = sprintf("DELETE FROM change_interior_cr_4 WHERE Interior_Id=%s",
                       	$Temp_Interior_Id);
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
		function Total_Change_Interior_Number($Dept_Id)
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Total_Change_Interior = "SELECT * FROM change_interior_cr_4    WHERE   Dept_Id=$Dept_Id";
				$Total_Change_Interior = mysql_query($query_Total_Change_Interior, $BMConnectionDB) or die(mysql_error());
				return $Total_Change_Interior;
			}
}//end_class
//*********************************************************************
class Exterior_Class  extends Interior_Class
{//start_class
//***********************************************************************
	function Get_Exterior($Temp_Exterior_Id)
		{
			$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  			mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
			$query_Manpulate_Recordset = "SELECT * FROM exterior_cr_2 WHERE Exterior_Id=$Temp_Exterior_Id";
			$Manpulate_Recordset = mysql_query($query_Manpulate_Recordset, $BMConnectionDB) or die(mysql_error());
			$row_Manpulate_Recordset = mysql_fetch_assoc($Manpulate_Recordset);
			return $row_Manpulate_Recordset;
		} 
//***********************************************************************
	function Insert_Exterior($Exterior_Id, $To, $Supject, $Message, $Sending_Date)
		{
		   
		   $insertSQL = sprintf("INSERT INTO exterior_cr_2 (Exterior_Id, `To`, Supject, Message, Sending_Date) VALUES (%s, %s, %s, %s, %s)",
                      $Exterior_Id, $To, $Supject, $Message, $Sending_Date
					   );
						
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$Result1 = mysql_query($insertSQL, $BMConnectionDB) or die(mysql_error());
		}
//*********************************************************************
	function Delete_Exterior($Temp_Exterior_Id)
		{
  				$deleteSQL = sprintf("DELETE FROM exterior_cr_2 WHERE Exterior_Id=%s",
                       	$Temp_Exterior_Id);
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
  				$Result1 = mysql_query($deleteSQL, $BMConnectionDB) or die(mysql_error());
		}//end_function
//*********************************************************************
		function Total_Exterior()
			{
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
  				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);
				$query_Mail_Recordset = "SELECT * FROM exterior_cr_2 ";
				$Mail_Recordset = mysql_query($query_Mail_Recordset, $BMConnectionDB) or die(mysql_error());
				return $Mail_Recordset;
			}
}//end_class
//*********************************************************************
/*
session_start();
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != ""))
{
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true"))
{
  session_unregister('MM_Username');
  session_unregister('MM_UserGroup');
  
  			if(file_exists('../../../Admin/Log_On.php'))
				{
					$Log_Out_GoTo ="../../../Admin/Log_On.php";
				}
			else if(file_exists('../../Admin/Log_On.php'))
				{
					$Log_Out_GoTo ="../../Admin/Log_On.php";
				}
			else if(file_exists('../Admin/Log_On.php'))
				{
					$Log_Out_GoTo ="../Admin/Log_On.php";
				}
			else if(file_exists('../Admin/Log_On.php'))
				{
					$Log_Out_GoTo ="../Admin/Log_On.php";
				}
			else if(file_exists('Admin/Log_On.php'))
				{
					$Log_Out_GoTo ="Admin/Log_On.php";
				}
	
  //$Log_Out_GoTo = "../Admin/Log_On.php";
  if ($Log_Out_GoTo) 
  {
    header("Location: $Log_Out_GoTo");
    exit;
  }
}
*/
//**************************************************************************************
class Generall_Index
{//start_class
var $Error_Path;
var $File_Path;
//*********************************************************************
	var $hostname_BMConnectionDB ;
	var $database_BMConnectionDB ;
	var $username_BMConnectionDB ;
	var $password_BMConnectionDB ;
//*********************************************************************
	function Generall_Index()
		{
			if(file_exists('../../../Connections/BMConnectionDB.php'))
				include('../../../Connections/BMConnectionDB.php');
			else if(file_exists('../../Connections/BMConnectionDB.php'))
				include('../../Connections/BMConnectionDB.php');
			else if(file_exists('../Connections/BMConnectionDB.php'))
					include('../Connections/BMConnectionDB.php');
			else if(file_exists('Connections/BMConnectionDB.php'))
					include('Connections/BMConnectionDB.php');
			$this->hostname_BMConnectionDB=$hostname_BMConnectionDB;
			$this->database_BMConnectionDB=$database_BMConnectionDB;
			$this->username_BMConnectionDB=$username_BMConnectionDB;
			$this->password_BMConnectionDB=$password_BMConnectionDB;
		}
//*************************************************************************
function Return_Index_Path($Name,$Part_Id)
	{
		if($this->Have_Permetions_Or_Not($Part_Id))
			{
				$Prefix="../";
				for($i=0;$i<5;++$i)
					{
						for($j=0;$j<i;++$j)
							$Prefix=$Prefix.$Prefix;
						$Name=$Prefix.$Name;
						if(file_exists($Name))
							{
								$this->File_Path=$Name;
								return $Name;
							}
						}
				}
			else
						{
							$Name="Message/Error/Error_Permetions.php";
							$Prefix="../";
							for($i=0;$i<5;++$i)
								{
									for($j=0;$j<i;++$j)
										$Prefix=$Prefix.$Prefix;
									$Name=$Prefix.$Name;
									if(file_exists($Name))
										return $Name;
								}
							}
	}
//*************************************************************************
	function Return_Index_Path_Persone($Name)
	{
		//if($x==5)
			//{
				$Prefix="../";
				for($i=0;$i<5;++$i)
					{
						for($j=0;$j<i;++$j)
							$Prefix=$Prefix.$Prefix;
						$Name=$Prefix.$Name;
						if(file_exists($Name))
							{
								$this->File_Path=$Name;
								return $Name;
							}
						}
				//}
			//if()//else
						//{
							$Name="Message/Error/Error_Permetions.php";
							$Prefix="../";
							for($i=0;$i<5;++$i)
								{
									for($j=0;$j<i;++$j)
										$Prefix=$Prefix.$Prefix;
									$Name=$Prefix.$Name;
									if(file_exists($Name))
										return $Name;
								}
							//}
	}
//*************************************************************************
	function Have_Select_Previleges($Case_To_Test,$Part_Id)
		{
			//$Valid_Operation_Object=new Valid_Operation();
			if($this->Check_Previleges($Case_To_Test,$Part_Id)==0)
				return false;
			 else 
			  	return true;	
		}
//*************************************************************************
	function Have_Insert_Previleges($Case_To_Test,$Part_Id)
		{
			if($this->Check_Previleges($Case_To_Test,$Part_Id)==0)
				return false;
			  else 
			  	return true;	
		}
//*************************************************************************
	function Have_Delete_Previleges($Case_To_Test,$Part_Id)
		{
			if($this->Check_Previleges($Case_To_Test,$Part_Id)==0)
				return false;
			  else 
			  	return true;	
		}
//*************************************************************************
	function Have_Update_Previleges($Case_To_Test)
		{
			if($this->Check_Previleges($Case_To_Test)==0)
				return false;
			  else 
			  	return true;	
		}
//*************************************************************************
		function Check_Previleges($caseToTest,$Part_Id)
			{//start function CheckPrevileges
				if($_SESSION['MM_Username'])
					$loginUsername=$_SESSION['MM_Username'];
				else
					$loginUsername="0"; 	
				$BMConnectionDB = mysql_pconnect($this->hostname_BMConnectionDB, $this->username_BMConnectionDB, $this->password_BMConnectionDB) or trigger_error(mysql_error(),E_USER_ERROR); 
				mysql_select_db($this->database_BMConnectionDB, $BMConnectionDB);

				$query_CheckPrevilegesRecoredset = "SELECT employee_admin_9.Employee_Id, employee_admin_9.User_Name, permeation_admin_5.Permetion_Id, part_user_permeation_admin_4.Part_Id,   department_admin_11.Department FROM employee_admin_9, permeation_admin_5, part_user_permeation_admin_4, department_admin_11 WHERE part_user_permeation_admin_4.User_Id=employee_admin_9.Employee_Id  AND part_user_permeation_admin_4.Part_Id=department_admin_11.Department_Id AND permeation_admin_5.Permetion_Id=part_user_permeation_admin_4.Permetion_Id AND  employee_admin_9.Department_Id=$Part_Id  AND employee_admin_9.User_Name='".$_SESSION['MM_Username']."'";
				$CheckPrevilegesRecoredset = mysql_query($query_CheckPrevilegesRecoredset, $BMConnectionDB) or die(mysql_error());
				$row_CheckPrevilegesRecoredset = mysql_fetch_assoc($CheckPrevilegesRecoredset);
				$totalRows_CheckPrevilegesRecoredset = mysql_num_rows($CheckPrevilegesRecoredset);
									
				$loginUsername="";
				$password="";
				//printf($_SESSION['MM_Username'].$totalRows_CheckPrevilegesRecoredset);
				if(isset($_SESSION['MM_Username']) )//&& isset($_POST['textfield']))
					{
						$loginUsername=$_SESSION['MM_Username'];
					}
				if($loginUsername=="admin" || $loginUsername=="issam")//&& $password=="11")
					return 1;
				if($totalRows_CheckPrevilegesRecoredset==0)
					return 0;
				do{
					//printf($row_CheckPrevilegesRecoredset['Permetion_Id']);
					if($row_CheckPrevilegesRecoredset['Permetion_Id']==$caseToTest)
						return 1;
					}while($row_CheckPrevilegesRecoredset = mysql_fetch_assoc($CheckPrevilegesRecoredset));
				return 0;
		}//end function CheckPrevileges
//*************************************************************************
//*************************************************************************
		function Have_Permetions_Or_Not($Part_Id)
			{
				//$Valid_Operation_Object =new Valid_Operation();
				if($this->Have_Select_Previleges(1,$Part_Id))
					{
						return true;
					}//end_if
				else
					return false;
			}//end_funcion
			
//*************************************************************************
}//end_class
?>